import { request } from '@inbiz/utils';
const version = InbizConfig.API_VERSION
// 获取消息分组
export async function getMessageGroup(params: any) {
  return request(
    `/inbiz/api/services/front/msgengine/v${version}/message/groupMsg`,
    {
      method: 'POST',
      data: params,
    },
  );
}

// 获取消息详情
export async function getMessageDetail(params: any) {
  return request(
    `/inbiz/api/services/front/msgengine/v${version}/message/${params.id}/messageById`,
    {
      params,
    },
  );
}

// 获取未读消息条数
export async function getMessageCount(params: any) {
  return request(
    `/inbiz/api/services/front/msgengine/v${version}/message/messageCount`,
    {
      method: 'POST',
      data: params,
    },
  );
}

// 获取消息记录
export async function getMessage(params: any) {
  return request(
    `/inbiz/api/services/front/msgengine/v${version}/message/message`,
    {
      method: 'POST',
      data: params,
    },
  );
}

// 获取消息记录
export async function getMessageAllTreeGroup(params: any) {
  return request(
    `/inbiz/api/services/front/msgengine/v${version}/msgGroup/messageGroupList/${params.appId}`,
    {
      params,
    },
  );
}

// 根据应用获取分组
export async function getMessageAllGroup(params: any) {
  const header = {};
  if (params.appId != 'other') {
    header.headers = {
      appId: params.appId[0],
    };
  }
  return request(
    `/inbiz/api/services/front/msgengine/v${version}/msgGroup/groupsPageList`,
    {
      ...header,
      params,
    },
  );
}

//  消息已读
export async function setReaded(params: any) {
  return request(
    `/inbiz/api/services/front/msgengine/v${version}/message/setMsgRead`,
    {
      method: 'POST',
      data: params,
    },
  );
}

//  获取消息引擎模板树
export async function getAppMessge(params: any) {
  return request(
    `/inbiz/api/services/front/msgengine/v${version}/msgGroup/MessageGroupList`,
    {
      params: {
        PageIndex: 1,
        PageSize: 999,
        ...params,
      },
    },
  );
}
